package com.eims.sls_app.fragment;

import com.eims.sls_app.ui.Luck_drawActivity;
import com.eims.sls_app.ui.RedPacketActivity;
import com.eims.sls_app.ui.adapter.NotDrawAdapter;
import com.eims.sls_app.view.MyToast;

import bls.juejin.cn.R;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

public class NotDrawFragment extends Fragment {
	
private static final String TAG = "NotDrawFragment";
private String[] title;
private NotDrawAdapter notDrawAdapter;
private ListView lv_not_draw;

public static NotDrawFragment newInstance(String[] title) {
        
        Bundle args = new Bundle();
        
        NotDrawFragment fragment = new NotDrawFragment();
        fragment.title = title;
       
        fragment.setArguments(args);
        return fragment;
    }
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view= inflater.inflate(R.layout.notwin_fragment, null);
		initView(view);
		return view;
	}

	private void initView(View view) {
		
		lv_not_draw = (ListView) view.findViewById(R.id.lv_not_draw);
		//Log.i(TAG, "title"+title[0]);
		if (title==null) {
			Toast.makeText(getActivity(), "你已经没有抽奖机会了", Toast.LENGTH_SHORT).show();
		}else {
			notDrawAdapter = new NotDrawAdapter(title, getActivity());
			lv_not_draw.setAdapter(notDrawAdapter);
		}
		
		lv_not_draw.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent intent = new Intent(getActivity(),Luck_drawActivity.class);

		        startActivity(intent);
				
			}
		});
		
	}
	
	

}
